package database;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import java.util.List;

import obj.Teachers;


public class DatabaseConnection {
    private static Connection con = null;
    List<Teachers> table;

    public DatabaseConnection() {
        super();
        
    }

    public static Connection getConectare() throws ClassNotFoundException, SQLException {
        if (con == null) {

            // Load the JDBC driver
            String driverName = "oracle.jdbc.driver.OracleDriver";
            Class.forName(driverName);

            // Create a connection to the database
            String serverName = "localhost";
            String portNumber = "1521";
            String sid = "emilia";
            String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
            String username = "UNIV";
            String password = "emilia";
            con = DriverManager.getConnection(url, username, password);
        }

        return con;
    }

    public static void inchidereConexiune() throws SQLException {
        if (con != null)
            con.close();
    }
}

